<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt"  uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="${pageContext.request.contextPath }/h-ui/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/h-ui/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/h-ui/lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/h-ui/lib/Hui-iconfont/1.0.6/iconfont.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/h-ui/lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
<title>添加</title>
</head>
<body onload="uploadSingleImg('${pageContext.request.contextPath }/upload/upload')">
<div class="pd-20">
  <form action="" method="post" class="form form-horizontal" id="add_HomeMessage_Form">
  <input type="hidden" name="state" value="${state}">
  <!-- centerState默认有两种状态：0或1。0、表示新增，1、表示修改。 -->
  <input type="hidden" name="centerState" value="${centerState}">
	<c:if test="${centerState ==0 }">
		<div class="row cl">
		    <label class="form-label col-1">中文内容：</label>
		    <div class="formControls col-10"> 
		    	<!-- 副文本编辑器，此处隐藏，因为这里面有点坑 -->
			<script id="editor" type="text/plain" style="width:100%;height:400px;"></script> 
			</div>
		</div>
	</c:if>
	<c:if test="${centerState ==1 }">
		<div class="row cl">
		    <label class="form-label col-1">中文内容：</label>
		    <div class="formControls col-10"> 
		    	<!-- 副文本编辑器，此处隐藏，因为这里面有点坑 -->
			<script id="editor" type="text/plain" style="width:100%;height:400px;"></script> 
			</div>
		</div>
	</c:if>
	<c:if test="${centerState ==0 }">
		<div class="row cl">
		    <label class="form-label col-1">英文内容：</label>
		    <div class="formControls col-10"> 
		    	<!-- 副文本编辑器，此处隐藏，因为这里面有点坑 -->
				<script id="editor2" type="text/plain" style="width:100%;height:400px;"></script> 
			</div>
		</div>
	</c:if>
	<c:if test="${centerState ==1 }">
		<div class="row cl">
		    <label class="form-label col-1">英文内容：</label>
		    <div class="formControls col-10"> 
		    	<!-- 副文本编辑器，此处隐藏，因为这里面有点坑 -->
				<script id="editor2" type="text/plain" style="width:100%;height:400px;"></script> 
			</div>
		</div>
	</c:if>
    <div class="row cl">
      <div class="col-9 col-offset-1">
        <a class="btn btn-primary radius"  onclick="operationdataValidate('../helpCenter/helpCenterDetails','.form-horizontal')">&nbsp;&nbsp;提交&nbsp;&nbsp;</a>
      </div>
    </div>
  </form>
</div>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/icheck/jquery.icheck.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/layer/2.1/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/js/H-ui.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/js/H-ui.admin.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/webuploader/0.1.5/webuploader.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/uploadSingleImg.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/jqthumb/jqthumb.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/ueditor/1.4.3/ueditor.all.js"> </script>
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/ueditor/1.4.3/ueditor.parse.js"> </script>
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/tableBtnGroup.js"></script>
<script type="text/javascript">
	$(function(){
		var content='${helpCenter.hContent }';
		var content2='${helpCenter.hContentEn }';
		var ue = UE.getEditor('editor');
		var ue2 = UE.getEditor('editor2');
	 	ue.addListener("ready", function () {
		    // editor准备好之后才可以使用
		    ue.setContent(content);
		    ue2.setContent(content2);
	    });
	});
	//提交
	function operationdataValidate(postUrl,formId){
		//editorValue
		var centerState='${centerState}';
		var textarea1=$('textarea').eq(0).val();
		var textarea2=$('textarea').eq(1).val();
		//如果是新增的信息
		if(centerState==0){
			if(textarea1==''){
				layer.msg('中文内容不能为空！',{icon:0,time:1000});
			}else if(textarea2==''){
				layer.msg('英文内容不能为空！',{icon:0,time:1000});
			}else{
				operationdata(postUrl,formId);
			}
		}else if(centerState==1){     //如果是修改的信息
			if(textarea1==''){
				layer.msg('中文内容不能为空！',{icon:0,time:1000});
			}else if(textarea2==''){
				layer.msg('英文内容不能为空！',{icon:0,time:1000});
			}else{
				operationdata(postUrl,formId);
			}
		}
	}

</script>
</body>
</html>